package cn.o.app.adapter;

import java.lang.reflect.Constructor;

import android.content.Context;

public class OAdapterX<DATA_ITEM> extends OAdapter<DATA_ITEM> {

	protected Constructor<? extends IItemView<DATA_ITEM>> mItemViewConstructor;

	public void setItemViewClass(
			Class<? extends IItemView<DATA_ITEM>> itemViewClass) {
		try {
			mItemViewConstructor = itemViewClass.getConstructor(Context.class);
		} catch (Exception e) {
			throw new IllegalArgumentException();
		}
	}

	@Override
	public IItemView<DATA_ITEM> getItemView() {
		try {
			IItemView<DATA_ITEM> itemView = mItemViewConstructor
					.newInstance(getContext());
			return itemView;
		} catch (Exception e) {
			return null;
		}
	}
}
